<?php
require_once '../inc/configuration.php';
require_once '../inc/connexion_bdd.php';
require_once '../inc/fonctions_sql.php';

$message_action = "";

$action = isset($_POST["action"]) ? $action = $_POST["action"] : "";

if($action==1) {
    
    $tab_name_form = array(
        "raison_sociale",
        "adresse",
        "telephone",
        "fax",
        "email",
        "observations"
    );
    
    $message_action = ajouter_donnees("entreprises", $tab_name_form);
}
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Ajouter une entreprise</title>
    </head>
    <body>
        <h1>Ajouter une Entreprise</h1>
        <?php if(!empty($message_action)) { ?>
            <div id="message_action" class="alert <?php echo $message_action["css_class"]; ?>"><?php echo $message_action["texte"]; ?></div>
        <?php } ?>
        <form  name="form_ajouter" id="form-ajouter" method="post">
            <table class="table table-bordered">
                    <tr>
                        
                        <th>
                            Raison Sociale : 
                        </th>
                        <td>
                            <input type="text" name="raison_sociale" id="raison_sociale" class="form-control" required>
                        </td>
                        
                    </tr>

                    <tr>

                        <th>
                            Adresse : 
                        </th>
                        <td>
                           <textarea name="adresse" id="adresse" class="form-control champ_textarea"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Telephone : 
                        </th>
                        <td>
                           <input type="tel" name="telephone" id="telephone" class="form-control">
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Fax : 
                        </th>
                        <td>
                           <input type="tel" name="fax" id="fax" class="form-control">
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Email : 
                        </th>
                        <td>
                           <input type="email" name="email" id="email" class="form-control">
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Observations : 
                        </th>
                        <td>
                            <textarea name="observations" id="observations" class="form-control champ_textarea"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <button type="submit" name="action" class="btn btn-success" value="1"><span class="glyphicon glyphicon-ok"></span>Ajouter</button> 
                        </td>
                    </tr>
                </table>
        </form>
    </body>
</html>
